<?php
	/*
	Profiler v1.2
	 - with +8 GMT
	 
	Author Eskie Maquilang
	*/
?>
<html>
<head><title>Profiler</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" href="https//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<!-- Latest compiled and minified JavaScript -->
<script src="https//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<?php
	function curPageName() {
	 return substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
	}
?>
</head>

<body>

<div class="container">	
	<?php
		if(!isset($_POST["loc"])) {
			?>

	<form method="POST" action="<?php echo curPageName(); ?>">		
		<h2>Where are you?</h2>
		<div class="input-group">
	      <input type="text" class="form-control" name="loc" placeholder="Just type in and click submit">
	      <span class="input-group-btn">
	        <button type="submit" class="btn btn-default">Submit</button>
	      </span>
	    </div><!-- /input-group -->

	    <input type="hidden" name="ip" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>" />
	    <input type="hidden" name="browser" value="<?php echo $_SERVER['HTTP_USER_AGENT']; ?>" />
	    <!-- <input type="hidden" name="ipproxy" value="<?php //echo $_SERVER['HTTP_X_FORWARDED_FOR']; ?>" /> -->
	</form>

			<?php
		}else
		{
			date_default_timezone_set("Asia/Manila");
			$loc = $_POST["loc"];
			$ip = $_POST["ip"];
			$browser = $_POST["browser"];
			$now = date("Y-m-d H:i:s");

			$txt = "[" . $now . "] " . $loc . "|" . $ip . "|" . $browser . PHP_EOL;
			?>
			<h2>Thank you!</h2>
			<?php echo "At <b>$now</b> you are at <b>$loc</b>, connected in <b>$ip</b>"; ?>
			<?php
			$file = fopen("IP-Address.txt","a+");
			fwrite($file,$txt);
			fclose($file);
		}
	?>
</div>

</body>
</html>